package org.shj.spark.operator;

import java.util.Arrays;
import java.util.List;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;

public class TakeOperator {

	public static void main(String[] args) {
		SparkConf conf = new SparkConf().setMaster("local").setAppName("TakeOperator");
		JavaSparkContext sc = new JavaSparkContext(conf);
		
		List<Integer> list = Arrays.asList(1,2,3,4,5);
		JavaRDD<Integer> numbers = sc.parallelize(list);
		
		List<Integer> take = numbers.take(3); // 取前3个
		
		for(Integer item : take){
			System.out.println(item);
		}
		
		sc.close();

	}

}
